package com.only4play.productcenter.infrastructure.convert;

import com.only4play.productcenter.api.constants.DirectionType;
import com.only4play.productcenter.api.constants.InOutStoreType;
import com.only4play.productcenter.api.constants.ProductType;

import java.util.Objects;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-02-27
 */
public class CustomMapper {

    public ProductType int2ProductType(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return ProductType.of(code).orElse(null);
    }

    public Integer productType2Int(ProductType productType) {
        return productType.getCode();
    }


    public DirectionType int2DirectionType(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return DirectionType.of(code).orElse(null);
    }

    public Integer directionType2Int(DirectionType directionType) {
        return directionType.getCode();
    }

    public InOutStoreType int2InOutStoreType(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        return InOutStoreType.of(code).orElse(null);
    }

    public Integer inOutStoreType2Int(InOutStoreType inOutStoreType) {
        return inOutStoreType.getCode();
    }


}
